<? //include/ORDERS_session.php

include("ORDERS.php");

require_once'../include/database.php';
$conn = new Connection();
$conn->NewConnection('localhost','ecommerce','root','batavia');
class SessionORDERS { 


 
 function find($id){
    
   global $conn;
   
   $query = "select ORDERID,CustomerID,PaymentID,OrderDate,RequiredDate,ShipDate,ShipperID,Freight,SalesTax,Timestamps,TransactStatus,ErrLoc,ErrMsg,Fullfilled,Deleted,Paid,PaymentDate from ORDERS where ORDERID='$id'";
   
   $run = mysql_query($query) or die(mysql_error());
   
   $row = mysql_fetch_array($run, MYSQL_ASSOC);
   
   $numRow = mysql_numrows($run);
   
   if($numRow)
   
   {
   
   $this->ORDERS= new ORDERS();


   
	$this->ORDERS->setORDERID($row['ORDERID']);

 
	$this->ORDERS->setCustomerID($row['CustomerID']);

 
	$this->ORDERS->setPaymentID($row['PaymentID']);

 
	$this->ORDERS->setOrderDate($row['OrderDate']);

 
	$this->ORDERS->setRequiredDate($row['RequiredDate']);

 
	$this->ORDERS->setShipDate($row['ShipDate']);

 
	$this->ORDERS->setShipperID($row['ShipperID']);

 
	$this->ORDERS->setFreight($row['Freight']);

 
	$this->ORDERS->setSalesTax($row['SalesTax']);

 
	$this->ORDERS->setTimestamps($row['Timestamps']);

 
	$this->ORDERS->setTransactStatus($row['TransactStatus']);

 
	$this->ORDERS->setErrLoc($row['ErrLoc']);

 
	$this->ORDERS->setErrMsg($row['ErrMsg']);

 
	$this->ORDERS->setFullfilled($row['Fullfilled']);

 
	$this->ORDERS->setDeleted($row['Deleted']);

 
	$this->ORDERS->setPaid($row['Paid']);

 
	$this->ORDERS->setPaymentDate($row['PaymentDate']);

 
}
return $this->ORDERS;
}

function insert($ORDERS){
	global $conn;
	$query = "insert into ORDERS(ORDERID,CustomerID,PaymentID,OrderDate,RequiredDate,ShipDate,ShipperID,Freight,SalesTax,Timestamps,TransactStatus,ErrLoc,ErrMsg,Fullfilled,Deleted,Paid,PaymentDate) values('".$ORDERS->getORDERID()."','".$ORDERS->getCustomerID()."','".$ORDERS->getPaymentID()."','".$ORDERS->getOrderDate()."','".$ORDERS->getRequiredDate()."','".$ORDERS->getShipDate()."','".$ORDERS->getShipperID()."','".$ORDERS->getFreight()."','".$ORDERS->getSalesTax()."','".$ORDERS->getTimestamps()."','".$ORDERS->getTransactStatus()."','".$ORDERS->getErrLoc()."','".$ORDERS->getErrMsg()."','".$ORDERS->getFullfilled()."','".$ORDERS->getDeleted()."','".$ORDERS->getPaid()."','".$ORDERS->getPaymentDate()."')";
 
 $parse=mysql_query($query);

 }
 
 function findall(){
	$query = "select ORDERID,CustomerID,PaymentID,OrderDate,RequiredDate,ShipDate,ShipperID,Freight,SalesTax,Timestamps,TransactStatus,ErrLoc,ErrMsg,Fullfilled,Deleted,Paid,PaymentDate from ORDERS";
	$parse=mysql_query($query);
	$datas = array();
	while($row=mysql_fetch_assoc($parse))
	{
		$data = array();$data['ORDERID'] = $row['ORDERID'];
		$data['CustomerID'] = $row['CustomerID'];
		$data['PaymentID'] = $row['PaymentID'];
		$data['OrderDate'] = $row['OrderDate'];
		$data['RequiredDate'] = $row['RequiredDate'];
		$data['ShipDate'] = $row['ShipDate'];
		$data['ShipperID'] = $row['ShipperID'];
		$data['Freight'] = $row['Freight'];
		$data['SalesTax'] = $row['SalesTax'];
		$data['Timestamps'] = $row['Timestamps'];
		$data['TransactStatus'] = $row['TransactStatus'];
		$data['ErrLoc'] = $row['ErrLoc'];
		$data['ErrMsg'] = $row['ErrMsg'];
		$data['Fullfilled'] = $row['Fullfilled'];
		$data['Deleted'] = $row['Deleted'];
		$data['Paid'] = $row['Paid'];
		$data['PaymentDate'] = $row['PaymentDate'];
		$datas[] = $data;
	 }
	return $datas;
	}
	function delete($ORDERS){
	$query = "delete from ORDERS where ORDERID= '".$ORDERS->getORDERID()."'";
	$parse=mysql_query($query);
	return $parse;

	}
	
	function update($ORDERS){
	$query = "update ORDERS set CustomerID= '".$ORDERS->getCustomerID()."',PaymentID= '".$ORDERS->getPaymentID()."',OrderDate= '".$ORDERS->getOrderDate()."',RequiredDate= '".$ORDERS->getRequiredDate()."',ShipDate= '".$ORDERS->getShipDate()."',ShipperID= '".$ORDERS->getShipperID()."',Freight= '".$ORDERS->getFreight()."',SalesTax= '".$ORDERS->getSalesTax()."',Timestamps= '".$ORDERS->getTimestamps()."',TransactStatus= '".$ORDERS->getTransactStatus()."',ErrLoc= '".$ORDERS->getErrLoc()."',ErrMsg= '".$ORDERS->getErrMsg()."',Fullfilled= '".$ORDERS->getFullfilled()."',Deleted= '".$ORDERS->getDeleted()."',Paid= '".$ORDERS->getPaid()."',PaymentDate= '".$ORDERS->getPaymentDate()."' where ORDERID= '".$ORDERS->getORDERID()."'";
$parse=mysql_query($query);

}


}
 //include/ORDERS_session.php